import turtle
import time

# 初始化时间
start_time = time.time()

# 定义初始位置和逃逸角度
positionHuman = (0.00, 86.00)
positionLion1 = (-150.00, 0.00)
positionLion2 = (150.00, 0.00)
positionLion3 = (0.00, 260.00)
escapeDegree = 240

# 设置画笔大小
turtle.pensize(3)

# 定义捕获距离阈值
capture_distance = 10

# 主循环
for x in range(100):
    # 绘制人的位置
    turtle.color("black")
    turtle.penup()
    turtle.goto(positionHuman)
    turtle.dot(2, "brown")
    turtle.pendown()
    turtle.setheading(escapeDegree)

    # 计算与人的距离
    lengthLion1 = turtle.distance(positionLion1)
    lengthLion2 = turtle.distance(positionLion2)

    # 根据距离调整逃逸角度并移动人
    if x >= 2:
        if lengthLion1 > lengthLion2:
            escapeDegree = escapeDegree - 20
            turtle.fd(10)
            print("1", escapeDegree)
        else:
            escapeDegree = escapeDegree + 20
            turtle.fd(10)
            print("2", escapeDegree)
    else:
        turtle.fd(10)
        print("3", escapeDegree)

    # 更新人的位置
    positionHuman = turtle.position()

    # 移动狮子 1
    turtle.color("green")
    turtle.penup()
    turtle.goto(positionLion1)
    turtle.dot(2, "green")
    turtle.pendown()
    positionLion1ToHuman = turtle.towards(positionHuman)
    turtle.setheading(positionLion1ToHuman)
    turtle.fd(15)
    positionLion1 = turtle.position()

    # 移动狮子 2
    turtle.color("red")
    turtle.penup()
    turtle.goto(positionLion2)
    turtle.dot(2, "red")
    turtle.pendown()
    positionLion2ToHuman = turtle.towards(positionHuman)
    turtle.setheading(positionLion2ToHuman)
    turtle.fd(20)
    positionLion2 = turtle.position()

    # 移动狮子 3
    turtle.color("brown")
    turtle.penup()
    turtle.goto(positionLion3)
    turtle.dot(2, "brown")
    turtle.pendown()
    positionLion3ToHuman = turtle.towards(positionHuman)
    turtle.setheading(positionLion3ToHuman)
    turtle.fd(20)
    positionLion3 = turtle.position()

    # 检查是否被抓住
    if (turtle.distance(positionLion1, positionHuman